﻿/****************************** Module Header ******************************\

Copyright (c) Gary Davidson

This source is subject to the Microsoft Public License.
See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
All other rights reserved.

THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
using System.IO;

namespace System.ServiceManger.Facade.ServerAPI
{

    public interface IWorkFlowParameterObject
    {}

    [AttributeUsage(AttributeTargets.Property)]
    public class WorkFlowPropertyAttribute : Attribute
    {
        public WorkFlowPropertyAttribute()
        {
            PropertyName = string.Empty;
        }

        public WorkFlowPropertyAttribute(string propertyName)
        {
            PropertyName = propertyName;
        }

        public string PropertyName { get; set; }
        
    }


    public static class SCSMWorkflow 
    {

        public static string GetWorkFlowXml(string connectorName)
        {
            var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), string.Format("ConnectorData\\{0}.{1}" + connectorName,"workflow.xml"));
            if (!File.Exists(path))
                throw new InvalidOperationException(string.Format("{0} does not exist", path));

            var fileInfo = new FileInfo(path);
           
                var reader = fileInfo.OpenText();
                return reader.ReadToEnd();
           

        }

        public static string GetScheduleXml(string connectorName)
        {
            var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), string.Format("ConnectorData\\{0}.{1}" + connectorName, "schedule.xml"));
          
            if (!File.Exists(path))
                throw new InvalidOperationException(string.Format("{0} does not exist", path));

            var fileInfo = new FileInfo(path);

            var reader = fileInfo.OpenText();
            return reader.ReadToEnd();


        }

        public static void AddWorkFlowType(string assemblyName, string workflowTypeName, IWorkFlowParameterObject workFlowPropertyObject)
        {

        }


      

    }

    
}
